home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / RTrace 1.0 / source / texture.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-23  |  22.0 KB  |  698 lines  |  [TEXT/KAHL]

  1. /*
  2.  * Copyright (c) 1988, 1992 Antonio Costa, INESC-Norte.
  3.  * All rights reserved.
  4.  *
  5.  * Code, ideas or suggestions were taken from the following people:
  6.  *
  7.  *  Roman Kuchkuda      - basic ray tracer
  8.  *  Mark VandeWettering - MTV ray tracer
  9.  *  Augusto Sousa       - overall, shading model
  10.  *  Craig Kolb          - textures
  11.  *  David Buck          - textures
  12.  *  Reid Judd           - portability
  13.  *
  14.  * Redistribution and use in source and binary forms are permitted
  15.  * provided that the above copyright notice and this paragraph are
  16.  * duplicated in all such forms and that any documentation,
  17.  * advertising materials, and other materials related to such
  18.  * distribution and use acknowledge that the software was developed
  19.  * by Antonio Costa, at INESC-Norte. The name of the author and
  20.  * INESC-Norte may not be used to endorse or promote products derived
  21.  * from this software without specific prior written permission.
  22.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  23.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  24.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  25.  */
  26. #include "defs.h"
  27. #include "extern.h"
  28.  
  29. /**********************************************************************
  30.  *    RAY TRACING - Scene (Textures) - Version 8.0.0                  *
  31.  *                                                                    *
  32.  *    MADE BY    : Antonio Costa, INESC-Norte, March 1990             *
  33.  *    MODIFIED BY: Antonio Costa, INESC-Norte, September 1992         *
  34.  **********************************************************************/
  35.  
  36. static rgb_ptr
  37. get_color_map(map_name)
  38.   char_ptr        map_name;
  39. {
  40.   int             i;
  41.   file_ptr        map;
  42.   rgb_ptr         color_map;
  43.  
  44.   OPEN(map, map_name, READ_TEXT);
  45.   if (IO_status != IO_OK)
  46.   {
  47.     WRITE(results, "Error: unable to open COLOR MAP (%s)\n", map_name);
  48.     FLUSH(results);
  49.     HALT;
  50.   }
  51.   ALLOCATE(color_map, rgb_struct, 256 );
  52.   for (i = 0; i < 256; POSINC(i))
  53.   {
  54.     get_valid(map, &(color_map[i].r), 0.0, 255.0, "COLOR MAP Red");
  55.     get_valid(map, &(color_map[i].g), 0.0, 255.0, "COLOR MAP Green");
  56.     get_valid(map, &(color_map[i].b), 0.0, 255.0, "COLOR MAP Blue");
  57.     ADVANCE(map);
  58.     color_map[i].r /= 255.0;
  59.     color_map[i].g /= 255.0;
  60.     color_map[i].b /= 255.0;
  61.   }
  62.   CLOSE(map);
  63.   return color_map;
  64. }
  65.  
  66.  
  67. static void
  68. get_image(image_name, image_map)
  69.   char_ptr        image_name;
  70.   image_map_ptr   image_map;
  71. {
  72.   REG unsigned char value;
  73.   unsigned int    width, height;
  74.   char str[10]; 
  75.   
  76.   OPEN(image_map->image, image_name, READ_BINARY);
  77.   if (IO_status != IO_OK)
  78.   {
  79.     WRITE(results, "Error: unable to open IMAGE (%s)\n", image_name);
  80.     FLUSH(results);
  81.     HALT;
  82.   }
  83.  
  84.  
  85.   switch (output_format)
  86.   {
  87.   case 0:       /* PIC */
  88.  
  89.     READ_CHAR(image_map->image, value);
  90.     if (IO_status != IO_OK)
  91.     {
  92.       WRITE(results, "Error: unable to read IMAGE HEADER (%s)\n", image_name);
  93.       FLUSH(results);
  94.       HALT;
  95.     }
  96.     width = value;
  97.     READ_CHAR(image_map->image, value);
  98.     if (IO_status != IO_OK)
  99.     {
  100.       WRITE(results, "Error: unable to read IMAGE HEADER (%s)\n", image_name);
  101.       FLUSH(results);
  102.       HALT;
  103.     }
  104.     width += 256 * value;
  105.  
  106.     READ_CHAR(image_map->image, value);
  107.     if (IO_status != IO_OK)
  108.     {
  109.       WRITE(results, "Error: unable to read IMAGE HEADER (%s)\n", image_name);
  110.       FLUSH(results);
  111.       HALT;
  112.     }
  113.     height = value;
  114.     READ_CHAR(image_map->image, value);
  115.     if (IO_status != IO_OK)
  116.     {
  117.       WRITE(results, "Error: unable to read IMAGE HEADER (%s)\n", image_name);
  118.       FLUSH(results);
  119.       HALT;
  120.     }
  121.     height += 256 * value;
  122.  
  123.     break;
  124.  
  125.   case 1:    /* PPM */
  126.  
  127.     READ_STRING( image_map->image, str );        /* P6 */
  128.     if ( (IO_status != IO_OK) || (strcmp( str, "P6" ) != 0) ) 
  129.     {
  130.       WRITE(results, "Error: problem reading PPM IMAGE HEADER (%s)\n", image_name);
  131.       FLUSH(results);
  132.       HALT;
  133.     }
  134.     READ_STRING( image_map->image, str );        /* width */
  135.     width = atoi( str );
  136.     READ_STRING( image_map->image, str );        /* height */
  137.     height = atoi( str );
  138.     READ_STRING( image_map->image, str );        /* 255 */
  139.     if ( (IO_status != IO_OK) || (strcmp( str, "255" ) != 0) )  
  140.     { 
  141.       WRITE(results, "Error: problem reading PPM IMAGE depth (%s)\n", image_name);
  142.       FLUSH(results); 
  143.       HALT; 
  144.     } 
  145.  
  146.     break;
  147.  
  148.   }
  149.  
  150.   if (width < 2)
  151.   {  
  152.     WRITE(results, "Error: bad IMAGE HEADER Width (%s)\n", image_name);
  153.     FLUSH(results);
  154.     HALT;   
  155.   }  
  156.  
  157.   if (height < 2)
  158.   {  
  159.     WRITE(results, "Error: bad IMAGE HEADER Height (%s)\n", image_name);
  160.     FLUSH(results);
  161.     HALT;
  162.   }  
  163.  
  164.   image_map->width = width;
  165.   image_map->height = height;
  166.   WRITE(results, "Image Map (%s) [%ux%u]\n", image_name, width, height);
  167.   FLUSH(results);
  168. }
  169. static texture_ptr
  170. get_object_texture(scene_objects, first_object, last_object)
  171.   int             scene_objects, *first_object, *last_object;
  172. {
  173.   int             i, id;
  174.   real            value;
  175.   texture_ptr     previous_texture, texture;
  176.  
  177.   if (texture_mode == 1)
  178.   {
  179.     get_valid(scene, &value, 0.0, (real) scene_objects, "OBJECT ID");
  180.     id = PRED(ROUND(value));
  181.     if (id < 0)
  182.       id = PRED(scene_objects);
  183.   }
  184.   else
  185.   {
  186.     get_valid(scene, &value, 1.0, (real) scene_objects, "OBJECT ID");
  187.     id = PRED(ROUND(value));
  188.   }
  189.   ALLOCATE(texture, texture_struct, 1 );
  190.   texture->next = NULL;
  191.   for (i = first_object[id]; i <= last_object[id]; POSINC(i))
  192.   {
  193.     if (object[i]->texture == NULL)
  194.       object[i]->texture = texture;
  195.     else
  196.     {
  197.       previous_texture = object[i]->texture;
  198.       while (previous_texture->next != NULL)
  199.         previous_texture = (texture_ptr) previous_texture->next;
  200.       if (previous_texture != texture)
  201.         previous_texture->next = (void_ptr) texture;
  202.     }
  203.   }
  204.   return texture;
  205. }
  206. static void
  207. get_transform(texture)
  208.   texture_ptr     texture;
  209. {
  210.   boolean         null_transf;
  211.   xyzw_ptr        inv_transf;
  212.  
  213.   ALLOCATE(texture->transf, xyzw_struct, 4 );
  214.   null_transf = TRUE;
  215.   get_valid(scene, &(texture->transf[0].x), X_MIN, X_MAX, "TRANSFORM X0");
  216.   null_transf = null_transf AND ABS(texture->transf[0].x) < ROUNDOFF;
  217.   get_valid(scene, &(texture->transf[0].y), Y_MIN, Y_MAX, "TRANSFORM Y0");
  218.   null_transf = null_transf AND ABS(texture->transf[0].y) < ROUNDOFF;
  219.   get_valid(scene, &(texture->transf[0].z), Z_MIN, Z_MAX, "TRANSFORM Z0");
  220.   null_transf = null_transf AND ABS(texture->transf[0].z) < ROUNDOFF;
  221.   get_valid(scene, &(texture->transf[0].w), W_MIN, W_MAX, "TRANSFORM W0");
  222.   null_transf = null_transf AND ABS(texture->transf[0].w) < ROUNDOFF;
  223.   get_valid(scene, &(texture->transf[1].x), X_MIN, X_MAX, "TRANSFORM X1");
  224.   null_transf = null_transf AND ABS(texture->transf[1].x) < ROUNDOFF;
  225.   get_valid(scene, &(texture->transf[1].y), Y_MIN, Y_MAX, "TRANSFORM Y1");
  226.   null_transf = null_transf AND ABS(texture->transf[1].y) < ROUNDOFF;
  227.   get_valid(scene, &(texture->transf[1].z), Z_MIN, Z_MAX, "TRANSFORM Z1");
  228.   null_transf = null_transf AND ABS(texture->transf[1].z) < ROUNDOFF;
  229.   get_valid(scene, &(texture->transf[1].w), W_MIN, W_MAX, "TRANSFORM W1");
  230.   null_transf = null_transf AND ABS(texture->transf[1].w) < ROUNDOFF;
  231.   get_valid(scene, &(texture->transf[2].x), X_MIN, X_MAX, "TRANSFORM X2");
  232.   null_transf = null_transf AND ABS(texture->transf[2].x) < ROUNDOFF;
  233.   get_valid(scene, &(texture->transf[2].y), Y_MIN, Y_MAX, "TRANSFORM Y2");
  234.   null_transf = null_transf AND ABS(texture->transf[2].y) < ROUNDOFF;
  235.   get_valid(scene, &(texture->transf[2].z), Z_MIN, Z_MAX, "TRANSFORM Z2");
  236.   null_transf = null_transf AND ABS(texture->transf[2].z) < ROUNDOFF;
  237.   get_valid(scene, &(texture->transf[2].w), W_MIN, W_MAX, "TRANSFORM W2");
  238.   null_transf = null_transf AND ABS(texture->transf[2].w) < ROUNDOFF;
  239.   get_valid(scene, &(texture->transf[3].x), X_MIN, X_MAX, "TRANSFORM X3");
  240.   null_transf = null_transf AND ABS(texture->transf[3].x) < ROUNDOFF;
  241.   get_valid(scene, &(texture->transf[3].y), Y_MIN, Y_MAX, "TRANSFORM Y3");
  242.   null_transf = null_transf AND ABS(texture->transf[3].y) < ROUNDOFF;
  243.   get_valid(scene, &(texture->transf[3].z), Z_MIN, Z_MAX, "TRANSFORM Z3");
  244.   null_transf = null_transf AND ABS(texture->transf[3].z) < ROUNDOFF;
  245.   get_valid(scene, &(texture->transf[3].w), W_MIN, W_MAX, "TRANSFORM W3");
  246.   null_transf = null_transf AND ABS(texture->transf[3].w) < ROUNDOFF;
  247.   if (null_transf)
  248.   {
  249.     FREE(texture->transf);
  250.     texture->transf = NULL;
  251.   } else
  252.   {
  253.     ALLOCATE(inv_transf, xyzw_struct, 4 );
  254.     inverse_transform(texture->transf, inv_transf);
  255.     FREE(texture->transf);
  256.     texture->transf = inv_transf;
  257.     normalize_transform(texture->transf);
  258.   }
  259. }
  260. void
  261. get_texture_null(scene_objects, first_object, last_object)
  262.   int             scene_objects, *first_object, *last_object;
  263. {
  264.   texture_ptr     texture;
  265.  
  266.   texture = get_object_texture(scene_objects, first_object, last_object);
  267.   get_transform(texture);
  268.   texture->type = NULL_TYPE;
  269.   ADVANCE(scene);
  270. }
  271. void
  272. get_texture_checker(scene_objects, first_object, last_object)
  273.   int             scene_objects, *first_object, *last_object;
  274. {
  275.   real            value;
  276.   texture_ptr     texture;
  277.   checker_ptr     checker;
  278.  
  279.   texture = get_object_texture(scene_objects, first_object, last_object);
  280.   get_transform(texture);
  281.   texture->type = CHECKER_TYPE;
  282.   ALLOCATE(checker, checker_struct, 1 );
  283.   texture->data = (void_ptr) checker;
  284.   get_valid(scene, &value, 1.0, (real) surfaces, "SURFACE ID");
  285.   checker->surface_id = PRED(ROUND(value));
  286.   ADVANCE(scene);
  287. }
  288. void
  289. get_texture_blotch(scene_objects, first_object, last_object)
  290.   int             scene_objects, *first_object, *last_object;
  291. {
  292.   real            value;
  293.   texture_ptr     texture;
  294.   blotch_ptr      blotch;
  295.  
  296.   texture = get_object_texture(scene_objects, first_object, last_object);;
  297.   get_transform(texture);
  298.   texture->type = BLOTCH_TYPE;
  299.   ALLOCATE(blotch, blotch_struct, 1 );
  300.   texture->data = (void_ptr) blotch;
  301.   get_valid(scene, &(blotch->scale), 0.0, 1.0, "BLOTCH SCALE");
  302.   get_valid(scene, &value, 1.0, (real) surfaces, "SURFACE ID");
  303.   blotch->surface_id = PRED(ROUND(value));
  304.   ADVANCE(scene);
  305. }
  306. void
  307. get_texture_bump(scene_objects, first_object, last_object)
  308.   int             scene_objects, *first_object, *last_object;
  309. {
  310.   texture_ptr     texture;
  311.   bump_ptr        bump;
  312.  
  313.   texture = get_object_texture(scene_objects, first_object, last_object);;
  314.   get_transform(texture);
  315.   texture->type = BUMP_TYPE;
  316.   ALLOCATE(bump, bump_struct, 1 );
  317.   texture->data = (void_ptr) bump;
  318.   get_valid(scene, &(bump->scale), 0.0, X_MAX, "BUMP SCALE");
  319.   ADVANCE(scene);
  320. }
  321. void
  322. get_texture_marble(scene_objects, first_object, last_object)
  323.   int             scene_objects, *first_object, *last_object;
  324. {
  325.   texture_ptr     texture;
  326.   marble_ptr      marble;
  327.   char            name[STRING_MAX];
  328.  
  329.   texture = get_object_texture(scene_objects, first_object, last_object);;
  330.   get_transform(texture);
  331.   texture->type = MARBLE_TYPE;
  332.   ALLOCATE(marble, marble_struct, 1 );
  333.   texture->data = (void_ptr) marble;
  334.   READ_STRING(scene, name);
  335.   if ((name[0] == '-') AND(name[1] == EOT))
  336.     marble->color = NULL;
  337.   else
  338.     marble->color = get_color_map(name);
  339.   ADVANCE(scene);
  340. }
  341. void
  342. get_texture_fbm(scene_objects, first_object, last_object)
  343.   int             scene_objects, *first_object, *last_object;
  344. {
  345.   real            value;
  346.   texture_ptr     texture;
  347.   fbm_ptr         fbm;
  348.   char            name[STRING_MAX];
  349.  
  350.   texture = get_object_texture(scene_objects, first_object, last_object);;
  351.   get_transform(texture);
  352.   texture->type = FBM_TYPE;
  353.   ALLOCATE(fbm, fbm_struct, 1 );
  354.   texture->data = (void_ptr) fbm;
  355.   get_valid(scene, &(fbm->offset), 0.0, 1.0, "FBM OFFSET");
  356.   get_valid(scene, &(fbm->scale), 0.0, X_MAX, "FBM SCALE");
  357.   get_valid(scene, &value, 0.0, 1.0, "FBM OMEGA");
  358.   get_valid(scene, &(fbm->lambda), 0.0, X_MAX, "FBM LAMBDA");
  359.   fbm->omega = POWER(fbm->lambda, -0.5 - value);
  360.   get_valid(scene, &(fbm->threshold), 0.0, 1.0, "FBM THRESHOLD");
  361.   get_valid(scene, &value, 0.0, X_MAX, "FBM OCTAVES");
  362.   fbm->octaves = ROUND(value);
  363.   READ_STRING(scene, name);
  364.   if ((name[0] == '-') AND(name[1] == EOT))
  365.     fbm->color = NULL;
  366.   else
  367.     fbm->color = get_color_map(name);
  368.   ADVANCE(scene);
  369. }
  370. void
  371. get_texture_fbm_bump(scene_objects, first_object, last_object)
  372.   int             scene_objects, *first_object, *last_object;
  373. {
  374.   real            value;
  375.   texture_ptr     texture;
  376.   fbm_bump_ptr    fbm_bump;
  377.  
  378.   texture = get_object_texture(scene_objects, first_object, last_object);;
  379.   get_transform(texture);
  380.   texture->type = FBM_BUMP_TYPE;
  381.   ALLOCATE(fbm_bump, fbm_bump_struct, 1 );
  382.   texture->data = (void_ptr) fbm_bump;
  383.   get_valid(scene, &(fbm_bump->offset), 0.0, 1.0, "FBM BUMP OFFSET");
  384.   get_valid(scene, &(fbm_bump->scale), 0.0, X_MAX, "FBM BUMP SCALE");
  385.   get_valid(scene, &value, 0.0, 1.0, "FBM BUMP OMEGA");
  386.   get_valid(scene, &(fbm_bump->lambda), 0.0, X_MAX, "FBM BUMP LAMBDA");
  387.   fbm_bump->omega = POWER(fbm_bump->lambda, -0.5 - value);
  388.   get_valid(scene, &value, 0.0, X_MAX, "FBM BUMP OCTAVES");
  389.   fbm_bump->octaves = ROUND(value);
  390.   ADVANCE(scene);
  391. }
  392. void
  393. get_texture_wood(scene_objects, first_object, last_object)
  394.   int             scene_objects, *first_object, *last_object;
  395. {
  396.   real            value;
  397.   texture_ptr     texture;
  398.   wood_ptr        wood;
  399.  
  400.   texture = get_object_texture(scene_objects, first_object, last_object);;
  401.   get_transform(texture);
  402.   texture->type = WOOD_TYPE;
  403.   ALLOCATE(wood, wood_struct, 1 );
  404.   texture->data = (void_ptr) wood;
  405.   get_valid(scene, &(value), -1.0, 1.0, "WOOD COLOR Red");
  406.   if (value < 0.0)
  407.   {
  408.     wood->color.r = 0.5;
  409.     wood->color.g = 0.5;
  410.     wood->color.b = 0.35;
  411.   } else
  412.   {
  413.     wood->color.r = value;
  414.     get_valid(scene, &(wood->color.g), 0.0, 1.0, "WOOD COLOR Green");
  415.     get_valid(scene, &(wood->color.b), 0.0, 1.0, "WOOD COLOR Blue");
  416.   }
  417.   ADVANCE(scene);
  418. }
  419.  
  420. void
  421. get_texture_round(scene_objects, first_object, last_object)
  422.   int             scene_objects, *first_object, *last_object;
  423. {
  424.   texture_ptr     texture;
  425.   round_ptr       round;
  426.  
  427.   texture = get_object_texture(scene_objects, first_object, last_object);
  428.   get_transform(texture);
  429.   texture->type = ROUND_TYPE;
  430.   ALLOCATE(round, round_struct, 1 );
  431.   texture->data = (void_ptr) round;
  432.   get_valid(scene, &(round->scale), 0.0, 1.0, "ROUND SCALE");
  433.   round->scale = 1.0 - round->scale;
  434.   ADVANCE(scene);
  435. }
  436. void
  437. get_texture_bozo(scene_objects, first_object, last_object)
  438.   int             scene_objects, *first_object, *last_object;
  439. {
  440.   texture_ptr     texture;
  441.   bozo_ptr        bozo;
  442.   char            name[STRING_MAX];
  443.  
  444.   texture = get_object_texture(scene_objects, first_object, last_object);;
  445.   get_transform(texture);
  446.   texture->type = BOZO_TYPE;
  447.   ALLOCATE(bozo, bozo_struct, 1 );
  448.   texture->data = (void_ptr) bozo;
  449.   get_valid(scene, &(bozo->turbulence), 0.0, X_MAX, "BOZO TURBULENCE");
  450.   READ_STRING(scene, name);
  451.   if ((name[0] == '-') AND(name[1] == EOT))
  452.     bozo->color = NULL;
  453.   else
  454.     bozo->color = get_color_map(name);
  455.   ADVANCE(scene);
  456. }
  457. void
  458. get_texture_ripples(scene_objects, first_object, last_object)
  459.   int             scene_objects, *first_object, *last_object;
  460. {
  461.   texture_ptr     texture;
  462.   ripples_ptr     ripples;
  463.  
  464.   texture = get_object_texture(scene_objects, first_object, last_object);;
  465.   get_transform(texture);
  466.   texture->type = RIPPLES_TYPE;
  467.   ALLOCATE(ripples, ripples_struct, 1 );
  468.   texture->data = (void_ptr) ripples;
  469.   get_valid(scene, &(ripples->frequency), 0.0, X_MAX, "RIPPLES FREQUENCY");
  470.   get_valid(scene, &(ripples->phase), 0.0, X_MAX, "RIPPLES PHASE");
  471.   get_valid(scene, &(ripples->scale), 0.0, X_MAX, "RIPPLES SCALE");
  472.   ADVANCE(scene);
  473. }
  474. void
  475. get_texture_waves(scene_objects, first_object, last_object)
  476.   int             scene_objects, *first_object, *last_object;
  477. {
  478.   texture_ptr     texture;
  479.   waves_ptr       waves;
  480.  
  481.   texture = get_object_texture(scene_objects, first_object, last_object);;
  482.   get_transform(texture);
  483.   texture->type = WAVES_TYPE;
  484.   ALLOCATE(waves, waves_struct, 1 );
  485.   texture->data = (void_ptr) waves;
  486.   get_valid(scene, &(waves->frequency), 0.0, X_MAX, "WAVES FREQUENCY");
  487.   get_valid(scene, &(waves->phase), 0.0, X_MAX, "WAVES PHASE");
  488.   get_valid(scene, &(waves->scale), 0.0, X_MAX, "WAVES SCALE");
  489.   ADVANCE(scene);
  490. }
  491. void
  492. get_texture_spotted(scene_objects, first_object, last_object)
  493.   int             scene_objects, *first_object, *last_object;
  494. {
  495.   texture_ptr     texture;
  496.   spotted_ptr     spotted;
  497.   char            name[STRING_MAX];
  498.  
  499.   texture = get_object_texture(scene_objects, first_object, last_object);;
  500.   get_transform(texture);
  501.   texture->type = SPOTTED_TYPE;
  502.   ALLOCATE(spotted, spotted_struct, 1 );
  503.   texture->data = (void_ptr) spotted;
  504.   READ_STRING(scene, name);
  505.   if ((name[0] == '-') AND(name[1] == EOT))
  506.     spotted->color = NULL;
  507.   else
  508.     spotted->color = get_color_map(name);
  509.   ADVANCE(scene);
  510. }
  511. void
  512. get_texture_dents(scene_objects, first_object, last_object)
  513.   int             scene_objects, *first_object, *last_object;
  514. {
  515.   texture_ptr     texture;
  516.   dents_ptr       dents;
  517.  
  518.   texture = get_object_texture(scene_objects, first_object, last_object);;
  519.   get_transform(texture);
  520.   texture->type = DENTS_TYPE;
  521.   ALLOCATE(dents, dents_struct, 1 );
  522.   texture->data = (void_ptr) dents;
  523.   get_valid(scene, &(dents->scale), 0.0, X_MAX, "DENTS SCALE");
  524.   ADVANCE(scene);
  525. }
  526. void
  527. get_texture_agate(scene_objects, first_object, last_object)
  528.   int             scene_objects, *first_object, *last_object;
  529. {
  530.   texture_ptr     texture;
  531.   agate_ptr       agate;
  532.   char            name[STRING_MAX];
  533.  
  534.   texture = get_object_texture(scene_objects, first_object, last_object);;
  535.   get_transform(texture);
  536.   texture->type = AGATE_TYPE;
  537.   ALLOCATE(agate, agate_struct, 1 );
  538.   texture->data = (void_ptr) agate;
  539.   READ_STRING(scene, name);
  540.   if ((name[0] == '-') AND(name[1] == EOT))
  541.     agate->color = NULL;
  542.   else
  543.     agate->color = get_color_map(name);
  544.   ADVANCE(scene);
  545. }
  546. void
  547. get_texture_wrinkles(scene_objects, first_object, last_object)
  548.   int             scene_objects, *first_object, *last_object;
  549. {
  550.   texture_ptr     texture;
  551.   wrinkles_ptr       wrinkles;
  552.  
  553.   texture = get_object_texture(scene_objects, first_object, last_object);;
  554.   get_transform(texture);
  555.   texture->type = WRINKLES_TYPE;
  556.   ALLOCATE(wrinkles, wrinkles_struct, 1 );
  557.   texture->data = (void_ptr) wrinkles;
  558.   get_valid(scene, &(wrinkles->scale), 0.0, X_MAX, "WRINKLES SCALE");
  559.   ADVANCE(scene);
  560. }
  561. void
  562. get_texture_granite(scene_objects, first_object, last_object)
  563.   int             scene_objects, *first_object, *last_object;
  564. {
  565.   texture_ptr     texture;
  566.   granite_ptr     granite;
  567.   char            name[STRING_MAX];
  568.  
  569.   texture = get_object_texture(scene_objects, first_object, last_object);;
  570.   get_transform(texture);
  571.   texture->type = GRANITE_TYPE;
  572.   ALLOCATE(granite, granite_struct, 1 );
  573.   texture->data = (void_ptr) granite;
  574.   READ_STRING(scene, name);
  575.   if ((name[0] == '-') AND(name[1] == EOT))
  576.     granite->color = NULL;
  577.   else
  578.     granite->color = get_color_map(name);
  579.   ADVANCE(scene);
  580. }
  581. void
  582. get_texture_gradient(scene_objects, first_object, last_object)
  583.   int             scene_objects, *first_object, *last_object;
  584. {
  585.   texture_ptr     texture;
  586.   gradient_ptr    gradient;
  587.   char            name[STRING_MAX];
  588.  
  589.   texture = get_object_texture(scene_objects, first_object, last_object);;
  590.   get_transform(texture);
  591.   texture->type = GRADIENT_TYPE;
  592.   ALLOCATE(gradient, gradient_struct, 1 );
  593.   texture->data = (void_ptr) gradient;
  594.   get_valid(scene, &(gradient->turbulence), 0.0, X_MAX,
  595.             "GRADIENT TURBULENCE");
  596.   get_valid(scene, &(gradient->direction.x), X_MIN, X_MAX,
  597.             "GRADIENT DIRECTION X");
  598.   get_valid(scene, &(gradient->direction.y), Y_MIN, Y_MAX,
  599.             "GRADIENT DIRECTION Y");
  600.   get_valid(scene, &(gradient->direction.z), Z_MIN, Z_MAX,
  601.             "GRADIENT DIRECTION Z");
  602.   if (LENGTH(gradient->direction) < ROUNDOFF)
  603.     runtime_abort("no GRADIENT DIRECTION");
  604.   READ_STRING(scene, name);
  605.   if ((name[0] == '-') AND(name[1] == EOT))
  606.     gradient->color = NULL;
  607.   else
  608.     gradient->color = get_color_map(name);
  609.   ADVANCE(scene);
  610. }
  611. void
  612. get_texture_image_map(scene_objects, first_object, last_object)
  613.   int             scene_objects, *first_object, *last_object;
  614. {
  615.   real            value;
  616.   texture_ptr     texture;
  617.   image_map_ptr   image_map;
  618.   char            name[STRING_MAX];
  619.  
  620.   texture = get_object_texture(scene_objects, first_object, last_object);;
  621.   get_transform(texture);
  622.   texture->type = IMAGE_MAP_TYPE;
  623.   ALLOCATE(image_map, image_map_struct, 1 );
  624.   texture->data = (void_ptr) image_map;
  625.   get_valid(scene, &(image_map->turbulence), 0.0, X_MAX,
  626.             "IMAGE MAP TURBULENCE");
  627.   get_valid(scene, &value, 0.0, X_MAX, "IMAGE MAP Mode");
  628.   image_map->once = (boolean) (value > ROUNDOFF);
  629.   get_valid(scene, &value, X_MIN, X_MAX, "IMAGE MAP U Axis");
  630.   switch (ROUND(value))
  631.   {
  632.   case X_AXIS:
  633.     image_map->u = X_AXIS;
  634.     break;
  635.   case Y_AXIS:
  636.     image_map->u = Y_AXIS;
  637.     break;
  638.   case Z_AXIS:
  639.     image_map->u = Z_AXIS;
  640.     break;
  641.   default:
  642.     runtime_abort("bad IMAGE MAP U Axis");
  643.     break;
  644.   }
  645.   get_valid(scene, &value, X_MIN, X_MAX, "IMAGE MAP V Axis");
  646.   switch (ROUND(value))
  647.   {
  648.   case X_AXIS:
  649.     image_map->v = X_AXIS;
  650.     break;
  651.   case Y_AXIS:
  652.     image_map->v = Y_AXIS;
  653.     break;
  654.   case Z_AXIS:
  655.     image_map->v = Z_AXIS;
  656.     break;
  657.   default:
  658.     runtime_abort("bad IMAGE MAP V Axis");
  659.     break;
  660.   }
  661.   if (image_map->u == image_map->v)
  662.     runtime_abort("same IMAGE MAP U and V Axis");
  663.   READ_STRING(scene, name);
  664.   get_image(name, image_map);
  665.   ADVANCE(scene);
  666. }
  667. void
  668. get_texture_gloss(scene_objects, first_object, last_object)
  669.   int             scene_objects, *first_object, *last_object;
  670. {
  671.   texture_ptr     texture;
  672.   gloss_ptr       gloss;
  673.  
  674.   texture = get_object_texture(scene_objects, first_object, last_object);;
  675.   get_transform(texture);
  676.   texture->type = GLOSS_TYPE;
  677.   ALLOCATE(gloss, gloss_struct, 1 );
  678.   texture->data = (void_ptr) gloss;
  679.   get_valid(scene, &(gloss->scale), 0.0, X_MAX, "GLOSS SCALE");
  680.   ADVANCE(scene);
  681. }
  682. void
  683. get_texture_bump3(scene_objects, first_object, last_object)
  684.   int             scene_objects, *first_object, *last_object;
  685. {
  686.   texture_ptr     texture;
  687.   bump3_ptr       bump3;
  688.  
  689.   texture = get_object_texture(scene_objects, first_object, last_object);;
  690.   get_transform(texture);
  691.   texture->type = BUMP3_TYPE;
  692.   ALLOCATE(bump3, bump3_struct, 1 );
  693.   texture->data = (void_ptr) bump3;
  694.   get_valid(scene, &(bump3->scale), 0.0, X_MAX, "BUMP3 SCALE");
  695.   get_valid(scene, &(bump3->size), 0.0, X_MAX, "BUMP3 SIZE");
  696.   ADVANCE(scene);
  697. }
  698.